<template>
  <el-dialog
    v-el-drag-dialog
    title="地址"
    :visible.sync="visible"
    width="1024px"
  >
    <baidu-map
      class="bm-view"
      :center="center"
      :zoom="zoom"
      @ready="handler"
    >
      <bm-marker
        :position="marker"
        :dragging="true"
        animation="BMAP_ANIMATION_BOUNCE"
      />
    </baidu-map>
  </el-dialog>
</template>

<script>

  export default {
    name: 'csm-location',
    data() {
      return {
        visible: false,
        center: { lng: 0, lat: 0 },
        marker: null,
        zoom: 3,
        show: false
      }
    },
    methods: {
      open(temp) {
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
          if (temp) {
            this.center.lng = temp.lon
            this.center.lat = temp.lat
            this.marker = this.center
          }
        })
      },
      handler({ BMap, map }) {
        // this.center.lng = 116.404
        // this.center.lat = 39.915
        this.zoom = 15
      }
    }
  }
</script>

<style lang="scss" scoped>
.bm-view {
  width: 100%;
  height: 500px;
}
</style>

